package net.zdreamer.geracomium.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;

import com.example.geracomium.R;

import net.zdreamer.geracomium.entity.PhotoInfos.PhotoInfo;
import net.zdreamer.geracomium.ui.more.PhotoGerallyActivity;
import net.zdreamer.geracomium.utils.tools_utils.ViewHolder;

import java.util.List;



public class QueryPhotoAdapter extends MyBaseAdapter<PhotoInfo> implements AdapterView.OnItemClickListener {
    private Context context;

    public QueryPhotoAdapter(Context context, List<PhotoInfo> list, int res) {
        super(context, list, res);
        this.context = context;
    }

    @Override
    protected View getView(int position, View convertView, ViewGroup parent, PhotoInfo value) {
        ImageView photo = ViewHolder.get(convertView, R.id.gridphoto);
        photo.setBackgroundResource((int) value.imageURL.get(position).get("photo"));
        return convertView;
    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent mIntent = new Intent(context, PhotoGerallyActivity.class);
        mIntent.putExtra("position",position);
        context.startActivity(mIntent);
    }
}
